<script setup lang="ts">
import { ref } from 'vue'
// 由父组件确定查看处方可不可以点击
const props = defineProps<{
  disabled?: boolean
}>()
const emit = defineEmits<{
  (e: 'on-delete'): void
  (e: 'on-preview'): void
}>()
const showPopover = ref(false)
const actions = [
  { text: '查看处方', disabled: props.disabled },
  { text: '删除订单' }
]
// 点击更多
const onSelect = (action: { text: string }, i: number) => {
  console.log(action, i)
  // 查看处方
  if (i === 0) {
    // 告诉父级组件 我要查看处方了
    emit('on-preview')
  }
  // 删除订单
  if (i === 1) {
    emit('on-delete')
  }
}
</script>

<template>
  <div class="cp-consult-more">
    <van-popover
      placement="top-start"
      v-model:show="showPopover"
      :actions="actions"
      @select="onSelect"
    >
      <template #reference> 更多 </template>
    </van-popover>
  </div>
</template>

<style lang="scss" scoped>
.cp-consult-more {
  flex: 1;
  color: var(--cp-tag);
}
</style>
